﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class Car
    {
        public string ID { get; set; }
        public string CarID { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string CarModel { get; set; }
        public string CarColorName { get; set; }
        public string CarColorValue { get; set; }
        public string LicensePlate { get; set; }
        public string Description { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public Car(DataAccessLayer.Car Car)
        {
            this.ID = Car.ID.ToString();
            this.CarID = Car.CarID.ToString();
            this.EditorUserID = Car.EditorUserID.ToString();
            this.EditorUserName = Car.sUser.Users.Last().Username;
            this.CarModel = Car.CarModel.Name;
            this.CarColorName = Car.Color.Name;
            this.CarColorValue = Car.Color.RGB;
            this.LicensePlate = Car.LicensePlate;
            this.Description = Car.Description;
            this.Timestamp = Car.Timestamp.ToHijriSolarString();
            this.BackColor = Car.IsDeleted ? "#FF5555" : "#FFFFFF";
        }

        public static List<Car> Convert(List<DataAccessLayer.Car> Cars)
        {
            return (Cars.ConvertAll(new Converter<DataAccessLayer.Car, Car>(p => (new Car(p)))));
        }
    }
}
